package com.dmap.run.controller.rpc;

import com.dmap.run.service.UserPortraitMovementService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @Author liuying
 * @Description 用户画像模块调用run模块Rpc请求
 * @Date 18:17 2018/7/2
 */
@Api(value = "用户画像模块调用run模块Rpc请求", description = "用户画像模块调用run模块Rpc请求")
@Controller
@RequestMapping(value = "/rpc/dmap-run-server/v1/userPortrait")
public class RpcUserPortraitController {

    @Resource
    private UserPortraitMovementService userPortraitPlanService;

    @ResponseBody
    @ApiOperation(value = "得到用户所有跑步、骑行、登山、游泳数据", notes = "得到用户所有跑步、骑行、登山、游泳数据")
    @RequestMapping(value = "select/selectUserMovementInfo", method = RequestMethod.GET)
    public String selectUserMovementInfo(@RequestParam Long userId) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.writeValueAsString(userPortraitPlanService.selectUserMovementInfo(userId));
        } catch (JsonProcessingException e) {
            return null;
        }
    }
}

